
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>First Consult</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script type="text/javascript">
function deleteDoc(index,data){
	document.getElementById(index).disabled = true;
	//alert(data);
	jQuery.ajax({url:"DoctorDetails", type:"post" , data:{data:data}, async:false, success:function(data){
		//alert("Post has been successfully deleted");
	}});
}
$(document).ready(function(){

	$("#postQues").hide();

	
	$("#postQuestionBtn").click(function()
{
	
			
	$("#postQues").show();
		
		
});
	$("#clearbtn1").click(function()
			{
				
		  $("#label").val("");
		  $("#question").val("");
		$("#postQues").hide();
				
			});
	
	
	$("#submitbtn1").click(function(){
		var label = $("#label").val();
		var question = $("#question").val();
		//alert(label);
		var userId = "<%= session.getAttribute("userid") %>";		
		if(label != "" & question != "")
				  $.ajax({url:"DoctorQues", type:"get" ,asynch:false, data: {label:label,question:question, userid: userId},success:function(data)
					  {
					  
			
					//  alert(status1);
					  $("#label").val("");
					  $("#question").val("");
		  	}  
				  });
		 
	});
	
	});
</script>
<style>
.row {
padding-top:10px;
}
.req {
color:red;
}
</style>
</head>

<body>
 <div id="middlePan">
   <div id="middlebodyPan">
   	<h1 > Network of Experts </h1><br>
   
	<jsp:useBean id="docListService" class="service.ViewDoctorList" scope="session"></jsp:useBean>
	<%String[] doctorsList = docListService.getDoctors(request.getSession().getAttribute("userid").toString(), request.getAttribute("spec").toString());%>
	<%	String doctor[]; %>
	<%	String doctorids= ""; %>
	<% if(doctorsList==null){ %>
	<h4 align="center">There are no doctors added by you for this specialization.</h4> 
	<%
	} else
	
	{ %>
	<div style="padding:20px;"><button align:"center;" style="padding:5px;" id="postQuestionBtn">Post a Question </button>
	  <a href="DocListPosts.jsp">Show Posts</a><br> 
	<div id="postQues" align="center;">
		      <div class="row"><span class="req">*</span> Asterisk fields are required</div>
		      <div class="row">
		        <label for="name">Post label <span class="req">*</span></label>
		        <input type="text" autofocus name="label" id="label" class="txt" tabindex="1" required>
		      </div>
		      <br>
		      <div class="row">
		        <label for="question">Question <span class="req">*</span></label>
		        <textarea rows="4" name="question" id="question" class="txt" tabindex="2" style="width: 349px; height: 39px;resize:none;" required></textarea>
		      </div>
		       <div class="row">
		        <input type="submit" id="submitbtn1" name="question" value="Post">
		         <input type="button" id="clearbtn1" name="clear"  value="Close">        
		      </div>
		</div></div>
		      <br>		
	 	         	<div class="doclist">
					  <ul>		
		<% 
		
		for( int i=0;i<doctorsList.length;i++ ){ 
			doctor = doctorsList[i].split("%");
		doctorids += doctor[4]+",";
		request.getSession().setAttribute("doctorid",doctorids);
		%>

						 <li>
						  <img src="images/Dr_<%=doctor[1] %>.jpg" width=100px height=100px>
						    <h3> <%=doctor[0] %>&nbsp;&nbsp;<%=doctor[1] %></h3>
						    <p><%=doctor[2] %> <br> <%=doctor[3] %><br></p>			
						 </li>		
<% } %>
	<% } %>
					  </ul>
					</div>					
 </div> 	     
  	</div>
	
	
</body>
</html>